#ifndef LAYER_H
#define LAYER_H

#include <QImage>
#include <QString>
#include <QGraphicsItem>
#include <QPainter>
#include <QRgb>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <QSemaphore>

#include "Filter/filter.h"


// class use to create a layer
class Layer : public QGraphicsItem
{


public:

    //************************************************************* Constructors
    Layer(int posX, int posY, int widthLayer, int heightLayer,int widthBoundingRect, int heightBoundingRect,QImage::Format format = QImage::Format_ARGB32 );
    Layer(int posX, int posY, int widthLayer, int heightLayer,QImage::Format format = QImage::Format_ARGB32);

    Layer(const QString & fileName);
    //************************************************************* Get
    int getWidth();
    int getHeight();
    QImage* getImage();
    QString getNomLayer();
    //************************************************************* Set
    void setSizeBoundingRect(int width, int height);
    int getWidthBoundingRect();
    int getHeightBoundingRect();

    void setImage(QImage* img);
    void setNomLayer(QString nomLayer);
    //************************************************************* Filter
    void applyFilter(Filter* filter);
    //************************************************************* Paint
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    //************************************************************* Copy
    Layer* copy();
    //************************************************************* Bounding
    QRectF boundingRect() const;
    //************************************************************* Transformation

    void rotate(qreal angle);
    void MiroirVertical();
    void MiroirHorizontal();

    //************************************************************* Etat Layer
    void changeEtatVisible();
    void changeValeurOpacite(int val);

 private:
    int widthBoundingRect;
    int heightBoundingRect;

    QString nomLayer;
    QImage* image;
    QSemaphore* semaphore;
};

#endif // LAYER_H
